package exa.unicen.edu.ringo.rmodel.builder.xstream;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

import exa.unicen.edu.ringo.rmodel.bean.Configuration;
import exa.unicen.edu.ringo.rmodel.bean.Node;
import exa.unicen.edu.ringo.rmodel.bean.Service;
import exa.unicen.edu.ringo.rmodel.builder.xstream.converter.ConfigurationConverter;

public class ConfigurationXStream extends XStream {

	public static ConfigurationXStream instance = new ConfigurationXStream();
	
	public ConfigurationXStream(){
		super(new DomDriver());
		
		this.alias("configuration", Configuration.class);
		this.registerConverter(new ConfigurationConverter());
		this.alias("node", Node.class);
		this.useAttributeFor(Node.class, "id");
		this.useAttributeFor(Node.class, "ip");
		this.alias("service", Service.class);
		this.useAttributeFor(Service.class, "id");
		this.useAttributeFor(Service.class, "port");
		this.useAttributeFor(Service.class, "type");
	}
}
